/*
 * @Descripttion: 
 * @Author: yubo
 * @Date: 2022-07-08 14:55:16
 * @LastEditTime: 2022-07-08 15:44:41
 */
#include <pybind11/embed.h>
#include <pybind11/stl.h>
#include <pybind11/cast.h>
#include <vector>
#include <unordered_map>
#include <string>
#include <iostream>

using namespace std;

namespace py = pybind11;

int main()
{
  py::scoped_interpreter guard; // start the interpreter and keep it alive

  //导入模块需要注意：如果这样，必须在当前路径运行程序才能正确导入python 模块
  auto test_md = py::module::import("tcontainer");

  vector<string> data1{ "first", "second", "third", "fourth", "fifth" };
  //vector<int> data1 {3, 4,5,6,7,8};

  //py::list pdata1 = py::cast(data1);
  //test_md.attr("handle_list")(pdata1);
  
  
  //auto test_md = py::module::import("tdict");
  /*
  unordered_map<string, double> data2
  {
    {"Stephen", 30},{"Klay", 11},{"Jordan", 3}
  };
  py::dict pdata2 = py::cast(data2);
  test_md.attr("handle_dict")(pdata2);
  */

  vector<unordered_map<string, string>> data3;
  data3.emplace_back(
    unordered_map<string, string>
    {
       {"Stephen", "30"},{"Klay", "11"},{"Jordan", "3"}
    }
  );
  data3.emplace_back(
    unordered_map<string, string>
    {
       {"Jayson", "0"},{"Al", "42"},{"Jaylen", "7"}
    }
  );

  py::list records = py::cast(data3);
  //test_md.attr("handle_embed_dictwithlist")(records);
  
  std::string result = (py::str)test_md.attr("handle_dictwithlist_tostr")(records);

  std::cout << result << '\n';

  getchar();
  return 0;
}